home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Lists / ListOf.h < prev    next >
Encoding:
Text File  |  1997-06-28  |  1.4 KB  |  52 lines  |  [TEXT/CWIE]

  1. // ListOf.h
  2.  
  3. #ifndef ListOf_h
  4. #define ListOf_h
  5.  
  6. #ifndef ListLink_h
  7. #include "ListLink.h"
  8. #endif
  9. #ifndef List_h
  10. #include "List.h"
  11. #endif
  12. #ifndef ListLoop_h
  13. #include "ListLoop.h"
  14. #endif
  15.  
  16. template < class Target >
  17. class ListOf: private List
  18.   {
  19.     typedef ListLink< Target > Link;
  20.     typedef ListLoop< Target > Loop;
  21.  
  22.     friend class ListLink< Target >;
  23.     friend class ListLoop< Target >;
  24.     
  25.     private:
  26.         static const ListLink<Target> *DownCast( const ListNode *n );
  27.         static ListLink<Target> *DownCast( ListNode *n );
  28.         
  29.     public:
  30.         const Link *First() const                                        { return DownCast( List::First() ); }
  31.         const Link *Last() const                                        { return DownCast( List::Last() ); }
  32.  
  33.         Link *First()                                                        { return DownCast( List::First() ); }
  34.         Link *Last()                                                        { return DownCast( List::Last() ); }
  35.         
  36.         List::IsEmpty;
  37.         
  38.         void Add( Link& n, BeforeStart )                                { List::Add( n, beforeStart ); }
  39.         void Add( Link& n, AfterEnd )                                    { List::Add( n, afterEnd ); }
  40.         
  41.         void Add( Link& n, Before, const Link& position )        { List::Add( n, before, position ); }
  42.         void Add( Link& n, After, const Link& position )        { List::Add( n, after, position ); }
  43.         
  44.         void Add( Link& n, Before, const Loop& position )        { List::Add( n, before, position ); }
  45.         void Add( Link& n, After, const Loop& position )        { List::Add( n, after, position ); }
  46.         
  47.         void Remove( Link& n )                                            { List::Remove( n ); }
  48.         List::RemoveAll;
  49.   };
  50.  
  51. #endif
  52.